//
//  ViewController.swift
//  swift-practice
//
//  Created by 余振涛 on 2021/7/15.
//

import UIKit

class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {

    var otherControllers: Array<Any> = [
        UICollectionViewDemoViewController.init(withTitle: "UICollectionView"),
        DemoTabBarViewController.init(withTitle: "TabBar"),
        UILabelViewController.init(withTitle: "UILabel"),
        UIButtonViewController.init(withTitle: "UIButton"),
        UIBezierViewController.init(withTitle: "UIBezier"),
        UIPickerViewController.init(withTitle: "Picker"),
        UIGestureViewController.init(withTitle: "Gesture")
    ]
    
    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
        super.init(nibName: nil , bundle: nil);
        self.title = "demo"
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = .white
        let tableView = UITableView(frame: self.view.frame, style:.plain)
        self.view.addSubview(tableView)
        tableView.backgroundColor = .white
        tableView.dataSource = self
        tableView.delegate = self
        tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
        self.test()
    }

    func test (){
        var t = HTTeacher()
        t.doSomeThing()
        
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return otherControllers.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let vc = self.otherControllers[indexPath.row] as! UIViewController
        let cell = tableView.dequeueReusableCell(withIdentifier: "cell",for: indexPath)
        cell.selectionStyle = .none
        cell.backgroundColor = .white
        cell.textLabel?.text = vc.title
        return cell
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let vc = self.otherControllers[indexPath.row] as! UIViewController
        self.navigationController?.pushViewController(vc, animated: true)
    }
    
}

